package core.product.model;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.ManyToMany ;
import javax.persistence.ManyToOne ;
import core.cms.model.Block;
import core.price.model.Price;

@Entity
@Table(name="product")
public class Product implements Serializable
{
	private static final long serialVersionUID = -8767337896773261247L;
	private Long uuid;
	private String sku ;
	private String name ;
	private String imagePath ;
	private String thumbnail ;
	private Set<ProductType> productType ;
	private Set<Price> price ;  
	private Set<ProductSearchKey> productSearchKeys ;
	private boolean avalable ;
	private boolean enabled ;
	private Block block;
	private String lat ;
	private String longs ;
	private ProductData productData ;
	private Set<Bedroom> bedrooms  ;
	private Set<Bathroom> bathrooms  ;
	
	@Id
	@GeneratedValue
	@Column(name="uuid")
	public Long getUuid() {
		return uuid;
	}
	public void setUuid(Long uuid) {
		this.uuid = uuid;
	}
	@ManyToMany(cascade = CascadeType.ALL , fetch = FetchType.EAGER)
	@JoinTable(name = "product_price", joinColumns = {@JoinColumn(name ="product_uuid") }, inverseJoinColumns = {@JoinColumn(name="price_uuid")})
	public Set<Price> getPrice() {
		return price;
	}
	public void setPrice(Set<Price> price) {
		this.price = price;
	}
	@Column(name="sku")
	public String getSku() {
		return sku;
	}
	public void setSku(String sku) {
		this.sku = sku;
	}
	@Column(name="name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name="imagepath")
	public String getImagePath() {
		return imagePath;
	}
	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}
	@Column(name="thumbnail")
	public String getThumbnail() {
		return thumbnail;
	}
	public void setThumbnail(String thumbnail) {
		this.thumbnail = thumbnail;
	}
	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinTable(name = "product_ProductType", joinColumns = {@JoinColumn(name ="product_uuid") }, inverseJoinColumns = {@JoinColumn(name="ProductType_uuid")})
	public Set<ProductType> getProductType() {
		return productType;
	}
	public void setProductType(Set<ProductType> productType) {
		this.productType = productType;
	}
	@Column(name="avalable")
	public boolean isAvalable() {
		return avalable;
	}
	public void setAvalable(boolean avalable) {
		this.avalable = avalable;
	}
	@Column(name="enabled")
	public boolean isEnabled() {
		return enabled;
	}
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	@JoinTable(name = "product_ProductSearchKey", joinColumns = {@JoinColumn(name ="product_uuid") }, inverseJoinColumns = {@JoinColumn(name="ProductSearchKey_uuid")})
	public Set<ProductSearchKey> getProductSearchKeys() {
		return productSearchKeys;
	}
	public void setProductSearchKeys(Set<ProductSearchKey> productSearchKeys) {
		this.productSearchKeys = productSearchKeys;
	}
	@ManyToOne(cascade = CascadeType.ALL)
	public Block getBlock() {
		return block;
	}
	public void setBlock(Block block) {
		this.block = block;
	}
	/**
	 * @return the lat
	 */
	@Column(name="lat")
	public String getLat() {
		return lat;
	}
	/**
	 * @param lat the lat to set
	 */
	public void setLat(String lat) {
		this.lat = lat;
	}
	/**
	 * @return the longs
	 */
	@Column(name="longs")
	public String getLongs() {
		return longs;
	}
	/**
	 * @param longs the longs to set
	 */
	public void setLongs(String longs) {
		this.longs = longs;
	}
	/**
	 * @return the productData
	 */
	@OneToOne(cascade = CascadeType.ALL)
	public ProductData getProductData() {
		return productData;
	}
	/**
	 * @param productData the productData to set
	 */
	public void setProductData(ProductData productData) {
		this.productData = productData;
	}
	/**
	 * @return the bedrooms
	 */
	@OneToMany(cascade = CascadeType.ALL , fetch = FetchType.EAGER)
	@JoinTable(name = "product_bedroom", joinColumns = {@JoinColumn(name ="product_uuid") }, inverseJoinColumns = {@JoinColumn(name="bedroom_uuid")})
	public Set<Bedroom> getBedrooms() {
		return bedrooms;
	}
	/**
	 * @param bedrooms the bedrooms to set
	 */
	public void setBedrooms(Set<Bedroom> bedrooms) {
		this.bedrooms = bedrooms;
	}
	/**
	 * @return the bathrooms
	 */
	@OneToMany(cascade = CascadeType.ALL , fetch = FetchType.EAGER)
	@JoinTable(name = "product_bathroom", joinColumns = {@JoinColumn(name ="product_uuid") }, inverseJoinColumns = {@JoinColumn(name="bedroom_uuid")})
	public Set<Bathroom> getBathrooms() {
		return bathrooms;
	}
	/**
	 * @param bathrooms the bathrooms to set
	 */
	public void setBathrooms(Set<Bathroom> bathrooms) {
		this.bathrooms = bathrooms;
	}
}
